package edu.vt.ece.rt.benchmark.intruder;

import java.util.Vector;


public class Dictionary {


	static String global_defaultSignatures[] = {
		    "about",
		    "after",
		    "all",
		    "also",
		    "and",
		    "any",
		    "back",
		    "because",
		    "but",
		    "can",
		    "come",
		    "could",
		    "day",
		    "even",
		    "first",
		    "for",
		    "from",
		    "get",
		    "give",
		    "good",
		    "have",
		    "him",
		    "how",
		    "into",
		    "its",
		    "just",
		    "know",
		    "like",
		    "look",
		    "make",
		    "most",
		    "new",
		    "not",
		    "now",
		    "one",
		    "only",
		    "other",
		    "out",
		    "over",
		    "people",
		    "say",
		    "see",
		    "she",
		    "some",
		    "take",
		    "than",
		    "that",
		    "their",
		    "them",
		    "then",
		    "there",
		    "these",
		    "they",
		    "think",
		    "this",
		    "time",
		    "two",
		    "use",
		    "want",
		    "way",
		    "well",
		    "what",
		    "when",
		    "which",
		    "who",
		    "will",
		    "with",
		    "work",
		    "would",
		    "year",
		    "your"
		};

		static long global_numDefaultSignature = global_defaultSignatures.length;
		Vector<String> dictionaryPtr; 

		public Dictionary ()
		{
		    dictionaryPtr = new Vector<String>();
		    
		        int s;
		        for (s = 0; s < global_defaultSignatures.length; s++) {
		            String sig = global_defaultSignatures[s];
		            boolean status = dictionaryPtr.add(sig);
		            assert(status);
		    }

		}




		static boolean
		dictionary_add (Dictionary dictionaryPtr, String str)
		{
		    dictionaryPtr.dictionaryPtr.add(str);
		    return true;
		}
 
		static String
		dictionary_get (Dictionary dictionaryPtr, int i)
		{
		    return dictionaryPtr.dictionaryPtr.get(i);
		}


	
		static String
		dictionary_match (Dictionary dictionaryPtr, String str)
		{
		    int s;
		    long numSignature = dictionaryPtr.dictionaryPtr.size();

		    for (s = 0; s < numSignature; s++) {
		        String sig = dictionary_get(dictionaryPtr, s);
		        if (str.indexOf(sig) != -1) {
		            return sig;
		        }
		    }

		    return null;
		}
		
	public static void main(String[] args) {

	    Dictionary dictionaryPtr;

	    dictionaryPtr = new Dictionary();
	    Dictionary.dictionary_add(dictionaryPtr, "test1");
	    String sig = dictionary_match(dictionaryPtr, "test1");
	    assert(sig.equals("test1"));
	    sig = dictionary_match(dictionaryPtr, "test1s");
	    assert(sig.equals("test1"));
	    assert(dictionary_match(dictionaryPtr, "test2")==null);

	    int s;
	    for (s = 0; s < global_numDefaultSignature; s++) {
	        sig = dictionary_match(dictionaryPtr, global_defaultSignatures[s]);
	        assert(sig.equals(global_defaultSignatures[s]));
	    }

	    
	}

}
